﻿using System;
using System.Collections.Generic;
using System.Text;
using RobotRace.utils.graph;
using RobotRace.engine.path;
using RobotRace.Geometry;
using RobotRace.engine.raceengine;
using RobotRace.engine.robossConnector;
using FIRADriverLibrary;

namespace RobotRace.engine.agents.implementation
{
    public abstract class AbstractAgent : Agent
    {
        public abstract String Name { get; set; }
        public abstract List<FIRARobotState> ControlledRobots { get; }
        
        public PathCreationStrategy pathCreationStrategy { 
            get {return _pathCreationStrategy; }
            set { 
                _pathCreationStrategy = value;
                path = _pathCreationStrategy.createPathGraph(originalCheckpoints);
            } 
        }

        public CheckpointManagementStrategy checkpointManagementStrategy { get; set; }


        protected List<Point2D> originalCheckpoints;
        protected PathGraph path;
        protected PathCreationStrategy _pathCreationStrategy;

        protected AbstractAgent(List<Point2D> originalPoints)
        {
            originalCheckpoints = originalPoints;
            pathCreationStrategy = new SinglePathCreator();
            path = pathCreationStrategy.createPathGraph(originalPoints);
            checkpointManagementStrategy = new SimpleCheckpointManagementStrategy();
        }

        public void recomputePath()
        {
            this.path = _pathCreationStrategy.createPathGraph(originalCheckpoints);
        }

        public abstract void configure(RaceEngine engine, RobossConnector connector);
        public abstract void step();
        public abstract void pause();
        public abstract void stop();
        
    }
}
